<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2015/10/11
 * Time: 18:05
 */

namespace Home\Model;
use Common\Common\MyPage;
use Think\Exception;
use Think\Log;
use Think\Model;
class RouteModel extends Model
{

    public function getRoute($title='',$page_size){
        $data = new \stdClass();

//        $now = date('y-m-d h:i:s',time());

        $where = array(
            'name'     =>  array('lIKE','%'.$title.'%'),
            'status'  => 1
        );

//        $where['endTime'] = array('GT',$now);

        $count = $this->where($where)->count();

        $Page = new MyPage($count,$page_size);

        $data->show=$Page->showData();

        $dds = $this->where($where)->order('sort desc,id desc')->limit($Page->firstRow.','.$Page->listRows)->select();

        $data->data = $dds;

        return $data;

    }

    public function getRouteById($id){

        $result = $this->where(array('id'=>$id))->find();

        $temp = htmlspecialchars_decode($result['text']);

        $result['text'] = $temp;

        return $result;

    }


}